<template>
  <div class="a-image">
    <img :src="src" :alt="item.title" @error="src = ''" :style="style" v-if="src"/>
    <img :src="placeholder" :alt="item.title" :style="style" v-else/>
  </div>
</template>

<script>
export default {
  name: 'lazy-image',
  props: {
    item: Object,
    mode: {
      type: String,
      default: 'contain'
    }
  },
  data() {
    return {
      placeholder: process.env.VUE_APP_FRONTDESK_URL + '/static/img/default/default-img-1.png',
      src: this.item.image,
      style: 'object-fit: ' + this.mode
    }
  },
  mounted() {
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
.a-image {
  height: 100%;
  width: 100%;
  img {
    display: block;
    background-color: #f8f8f8;
    height: 100%;
    width: 100%;
    object-fit: contain;
  }
}
</style>